import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;


export class NodeExtension
{
    public static visitAllDescendants(res:Node,callBack:(node:Node)=>void):void{
        for(let i = 0;i<res.children.length;i++)
        {
            if(res.children[i].children.length>0)
                NodeExtension.visitAllDescendants(res.children[i],callBack)
            
            callBack(res.children[i])
        }
    }

    public static visitNodeTree(res:Node,callBack:(node:Node)=>void):void{
        callBack(res)
        NodeExtension.visitAllDescendants(res,callBack)
    }
}